<%-- 
    Document   : ricardo
    Created on : 17/06/2011, 14:24:29
    Author     : Fatec
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Mostrando a data/hora do servidor</h1>
        <%
        java.sql.Connection con = br.com.fatecz.database.ConnectionPool.getConnection();
        java.sql.Statement stmt = con.createStatement();
        java.sql.ResultSet rs = stmt.executeQuery("SELECT now() FROM DUAL;");

        if(rs.next()){
            out.print("Data/hora do servidor: ");
            out.println(rs.getString(1));
        }
        %>

        <h1>Listando os usuários</h1>
        <table border="1">
            <tr>
                <th>Nome</th>
                <th>Email</th>
            </tr>
            <%
            java.sql.ResultSet rs2 = stmt.executeQuery("SELECT nome, email FROM usuarios;");
            while(rs2.next()){
            %>
            <tr>
                <td> <%= rs2.getString("nome") %> </td>
                <td> <%= rs2.getString("email") %> </td>
            </tr>
            <%
            }
            %>
        </table>
        <%
        rs2.close();
        rs.close();
        stmt.close();
        con.close();
        %>
    </body>
</html>
